<?php
/*
Overmundo, cultura de todo o Brasil
Desenvolvido pela Tecnopop para o Núcleo de Idéias Movimento
Copyright (C) 2006  Núcleo de Idéias Movimento

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

*/


$nivelPagina = "desconhecido";
$secaoAtual = "blogs";

include('../lib/checa_login.php');
 
 
require_once('../lib/class.site.php');
require_once('../lib/class.overmundo.php');
require_once('../lib/class.conecta.php');
require_once("../lib/class.usuario.php");
require_once("../lib/class.blog.php");
require_once("../lib/class.artigo.php");
require_once("../lib/class.paginacao.php");

session_start();

if (!isset($minhaConexao))  {
	$minhaConexao = new Conecta();
}
if (!isset($meuSite)) {
	$meuSite = new Overmundo();
}

if (!isset($meuSite->linkid)) { 
	$meuSite->linkid = $minhaConexao->linkid;
}
if ($titulo = $meuSite->LimpaCampo($_GET["tit"])) {
	$resBlogs = $meuSite->OvermundoListaBlogs("tituloUnicoBlog = '$titulo'", "");
	if ($row = mysql_fetch_array($resBlogs)){
		$thisBlog = new Blog($meuSite->linkid, $row["codBlog"]);
	} else  {
			//die("3");
		header("location: ../blogs/blogs.php");
		exit;
	}
	
} elseif ($codigo = $meuSite->LimpaCampo($_GET["blog"])) { 
	$thisBlog = new Blog($meuSite->linkid, $codigo);
} else  {
			//die("3");
	header("location: ../blogs/blogs.php");
	exit;
}

if (($thisBlog->PegaStatus() == "ativo")
  || ($meuSite->OvermundoLiberaNivelParaUsuario("editor", $usuarioLogado->PegaNivel()))) {

	$resAutores = $thisBlog->ListaAutores();
	
	$conjunto="";
	
	
	
	
	
	
	 if ($termo = stripslashes($thisBlog->PegaTitulo())) {
        	$conjunto = "<a href='../blog/" . $thisBlog->PegaTituloUnico() . "' style='color:#fff;'><strong>$termo</strong></a>";
    	}
    	
	if ($usuarioLogado->PegaStatus() == "ativo") {
    	if ($thisBlog->LiberaBlogger($usuarioLogado->PegaCodUsuario())) {
	    	$linksEditor = '<a href="../blogs/edita_blog.php?editada=' . $thisBlog->PegaCodBlog() . '"><img src="../images/editar.gif" alt="editar" width="11" height="13" border="0"></a>'; 
//	    	$linksEditor .= '&nbsp;<a href="../blogs/descarta_blog.php?descartada=' . $thisBlog->PegaCodBlog() . '"><img src="../images/apagar.gif" alt="apagar" width="11" height="13" border="0"></a>'; 
	    	$linksEditor .= '&nbsp;<a  href="../blogs/envia_artigo.php?blog=' . $thisBlog->PegaCodBlog() . '"><span class="blog padding10bottom">posta artigo novo</span></a>'; 
    	 }
    	 if ($glbUsuarioEhEditor) {
	    	$linksEditor = '<a href="../blogs/edita_blog.php?editada=' . $thisBlog->PegaCodBlog() . '"><img src="../images/editar.gif" alt="editar" width="11" height="13" border="0"></a>'; 
	    	$linksEditor .= '&nbsp;<a href="../blogs/descarta_blog.php?descartada=' . $thisBlog->PegaCodBlog() . '"><img src="../images/apagar.gif" alt="apagar" width="11" height="13" border="0"></a>'; 
    	 }
	 }
	 
	 if ($linksEditor) {
        if ($conjunto) {
        	$conjunto .=  " $linksEditor";
    	} else {
        	$conjunto =  "$linksEditor";
    	}
	 }
		if ($conjunto) {
				$linhaTitulo = "$conjunto";
		} else {
			$linhaTitulo = "";
		}
	
	
	
	
	

	
	$conjunto="";
	
    if ($termo = stripslashes($thisBlog->PegaTagline())) {
    	$conjunto = "<strong>$termo</strong>";
	}
	
	if ($conjunto) {
			$linhaTagline = "$conjunto";
	} else {
		$linhaTagline = "";
	}
	//$paginacao = new Paginacao(mysql_num_rows($resAutores), $page);

} else  {
			//die("3");
	header("location: ../blogs/blogs.php");
	exit;
}


?>
<html>
<head>
<title>.: overmundo :.</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>

<script type="text/javascript">
_uacct = "UA-98715-2";
urchinTracker();
</script>
<link rel="stylesheet" type="text/css" href="/templates/css/utilitarios.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/templates/css/estilos.css" />
<script src="../js/ajaxInit.js" language="javascript" type="text/javascript"></script>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0" id="tabela">
	<tr>
				  <td valign="top"><table width="770" height="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                    <tr>
                      <td id="topo"><? include("../includes/topo.php"); ?></td>
                    </tr>
                    <tr>
                      <td colspan="2" valign="top" style="padding-top:9px;">
                        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                            
                            <tr>
                              <td colspan="2" align="left" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
                                <tr>
                                  <td height="19" colspan="3"><table width="100%" border="0" cellpadding="0" cellspacing="0" background="../images/fundo_verde.gif">
                                    <tr>
                                      <td width="9"><img src="../images/canto_verde_e.gif" width="9" height="80" alt="canto_esquerdo"></td>
                                      <td width="409" valign="bottom" class="txt24 padding10bottom"><strong class="branco">
                                        <?=$linhaTitulo?>
                                        &nbsp;<a href="../rss/rss_blog.php?titulo=<?=$thisBlog->PegaTituloUnico()?>"><img src="../images/rss.gif" alt="rss" width="24" height="13" border="0" align="bottom" title="Canal RSS deste blog"></a><br>
                                        <span class="txt20 verde">
                                          <?=$linhaTagline?>
                                        </span></strong></td>
                                      <td align="right" valign="bottom" class="blog padding10bottom" colspan=2><strong><a href="../blogs/sobre.php?blog=<?=$thisBlog->PegaCodBlog()?>">sobre</a></strong><span class="verde"> | </span> <strong><a href="../blogs/arquivo_blog.php?blog=<?=$thisBlog->PegaCodBlog()?>">arquivo <span class="verde"></span></a></strong></td>
                                      <td width="7"><img src="../images/cando_verde_d.gif" width="7" height="80" alt="cando_direito"></td>
                                    </tr>
                                  </table></td>
                                </tr>
                                <tr>
                                  <td width="1%">&nbsp;</td>
                                  <td width="98%"><table width="100%" border="0" cellpadding="0" cellspacing="0">
                                            <tr>
                                              <td valign="top" class="txt13 preto">
											  
<div class="padding10top">
<div class="txt24 padding10top"><strong>Sobre este blog</strong></div><br>


<?=stripslashes(nl2br($thisBlog->PegaSobre()))?></div></td>
                                            </tr>
                                            <tr>
                                              <td valign="top" class="txt11">&nbsp;</td>
                                            </tr>
                                        </table><table width="100%" border="0" cellpadding="0" cellspacing="0" class="margin10top"  id="tabela7">
                                    <tr>
                                      <td width="10" align="left" valign="bottom" background="../images/fundo_amarelo_46.gif"><img src="../images/overmundo_35.gif" width="6" height="20" alt="canto_esquerdo"></td>
                                      <td width="490" background="../images/fundo_amarelo_46.gif"><span class="cinza2 txt10"><strong>autor(es) deste blog  </strong></span> </td>
                                      <td width="15" align="right" background="../images/fundo_amarelo_46.gif"><img src="../images/overmundo_37.gif" width="9" height="20" alt="canto_direito"></td>
                                    </tr>
                                  </table></td>
                                </tr>
                                <tr>
                                  <td width="1%">&nbsp;
											 <script src="../js/ajaxInit.js" language="javascript" type="text/javascript"></script>								  </td>
                                  <td width="98%"><?
	 	$thisAutor = new Usuario($meuSite->linkid, $thisBlog->PegaCodEditor());
	 	
	 	$conjunto="";
	 	
        if ($termo = $meuSite->OvermundoMunicipio($thisAutor->PegaCodMunicipio())) {
	        if ($conjunto) {
	        	$conjunto .=  ", $termo";
        	} else {
	        	$conjunto =  "$termo";
        	}
    	}
    	
        if ($termo = $thisAutor->PegaEstado()) {
	        $conjunto .= ($termo == "WW" ? "" : " ($termo)");
    	}
    	$linhaLocal = $conjunto;
    	
	 	
		$qualArquivo = "../uploads/usuarios/img/perfis/" . $thisAutor->PegaImagem();
		if (is_file($qualArquivo)) {
			$dimensoesImagemAutor = getimagesize($qualArquivo);
			$wAutor=$dimensoesImagemAutor[0];
			$hAutor= $dimensoesImagemAutor[1];
			$imagemAutor = $qualArquivo;
			
			if ($wAutor == $hAutor) {
				$propDimensaoAutor = "height=\"59\" width=\"59\" ";
			} else if ($wAutor > $hAutor) {
				$propDimensaoAutor = "width=\"59\" ";
			} else {
				$propDimensaoAutor = "height=\"59\" ";
			}
		} else {
			unset($dimensoesImagemAutor);
			unset($wAutor);
			unset($hAutor);
			unset($imagemAutor);
		}
			
		
		$conjunto="";
        if ($termo = $thisAutor->PegaApelido()) {
        	$conjunto =  "<a href='../perfis/" .  $thisAutor->PegaTituloUnico() . "'><strong>" . $termo . "</strong></a>";
    	}
    	$linhaAutor = $conjunto;
?>
		
								<table width="100%" border="0" cellspacing="0" cellpadding="0"  id="tabela8">
                                    <tr>
                                      <td width="15%" valign="bottom" class="padding10top">
<?

	if (isset($dimensoesImagemAutor)) {
		
?><img src="<?php print($imagemAutor); ?>" <?=$propDimensaoAutor?> border="0"><?
		} else {
?>
                                      <img src="../images/img.gif" alt="<?=$thisAutor->PegaApelido()?>" width="59" height="59">
<?
	}

?></td>
                                      <td width="85%" valign="bottom" class="txt18"><?=$linhaAutor . ($thisBlog->PegaCodEditor() == $thisAutor->PegaCodUsuario() ? " (editor)" : "")?><br>
                                          <span class="txt13"> <?=$linhaLocal?></span></td>
                                    </tr>
                                  </table>
								  <hr>
<?
	if ($resAutores) {
		while ($rowAutor = mysql_fetch_array($resAutores)){
		 	$thisAutor = new Usuario($meuSite->linkid, $rowAutor["codUsuario"]);
		 	
		 	$conjunto="";
		 	
	        if ($termo = $meuSite->OvermundoMunicipio($thisAutor->PegaCodMunicipio())) {
		        if ($conjunto) {
		        	$conjunto .=  ", $termo";
	        	} else {
		        	$conjunto =  "$termo";
	        	}
	    	}
	    	
	        if ($termo = $thisAutor->PegaEstado()) {
		        $conjunto .= ($termo == "WW" ? "" : " ($termo)");
	    	}
	    	$linhaLocal = $conjunto;
	    	
		 	
			$qualArquivo = "../uploads/usuarios/img/perfis/" . $thisAutor->PegaImagem();
			if (is_file($qualArquivo)) {
				$dimensoesImagemAutor = getimagesize($qualArquivo);
				$wAutor=$dimensoesImagemAutor[0];
				$hAutor= $dimensoesImagemAutor[1];
				$imagemAutor = $qualArquivo;
				
				if ($wAutor == $hAutor) {
					$propDimensaoAutor = "height=\"59\" width=\"59\" ";
				} else if ($wAutor > $hAutor) {
					$propDimensaoAutor = "width=\"59\" ";
				} else {
					$propDimensaoAutor = "height=\"59\" ";
				}
			} else {
				unset($dimensoesImagemAutor);
				unset($wAutor);
				unset($hAutor);
				unset($imagemAutor);
			}
				
			
			$conjunto="";
			
	        if ($termo = $thisAutor->PegaApelido()) {
	        	$conjunto =  "<a href='../perfis/" .  $thisAutor->PegaTituloUnico() . "'><strong>" . $termo . "</strong></a>";
	    	}
	    	$linhaAutor = $conjunto;
?>
		
								<table width="100%" border="0" cellspacing="0" cellpadding="0"  id="tabela8">
                                    <tr>
                                      <td width="15%" valign="bottom" class="padding10top"><?

	if (isset($dimensoesImagemAutor)) {
		
?><img src="<?php print($imagemAutor); ?>" <?=$propDimensaoAutor?> border="0"><?
		} else {
?>
                                      <img src="../images/img.gif" alt="<?=$thisAutor->PegaApelido()?>" width="59" height="59">
<?
	}
?></td>
                                      <td width="85%" valign="bottom" class="txt18"><?=$linhaAutor . ($thisBlog->PegaCodEditor() == $thisAutor->PegaCodUsuario() ? " (editor)" : "")?><br>
                                          <span class="txt13"> <?=$linhaLocal?></span></td>
                                    </tr>
                                  </table>
								  <hr>
<?
	}
}
?>
								  <!--8-->
								  </td>
                                  <td width="1%">&nbsp;</td>
                                </tr>
                              </table>
                                <br></td>
                              <td width="255" align="right" valign="top">
							  
							  
							  <!-- coluna direita -->
					
								<? include("../includes/meu_painel_padrao.php"); ?>

								
								
								
								<!-- /coluna direita -->							  </td>
                            </tr>
                            <tr>
                              <td width="6" valign="top"><img src="../images/spacer.gif" width="6" height="1"></td>
                              <td width="509" valign="top" class="txt11">&nbsp;</td>
                              <td align="right" valign="top">&nbsp;</td>
                            </tr>
                      </table></td>
                    </tr>
                    <tr>
                      <td colspan="2" id="footer"><? include("../includes/footer.php"); ?></td>
                    </tr>
                  </table></td>
	</tr>
</table>
</body>
</html>
